In diesem Skript werden die Informationen aus den vorangegangenen Skripten so aufbereitet, dass nur noch die zentralen Attribute vorhanden sind.

Daten einlesen

Die Daten aus dem vorhergehenden Arbeitsschritt werden eingelesen.

load("output/05_output/geom/05_rolle_bld_out.Rdata")

Bereinigung

Klassifikation Wohnen / !Wohnen

rolle_bld_out$nutzung<-NA
rolle_bld_out$nutzung[rolle_bld_out$sia=="efh"|
                        rolle_bld_out$sia=="mfh"] <- "wohnen"

rolle_bld_out$nutzung[rolle_bld_out$sia=="alterheim"|
                        rolle_bld_out$sia=="mischnutzung"|
                        rolle_bld_out$sia=="krankenhaus"|
                        rolle_bld_out$sia=="hotel"|
                        rolle_bld_out$sia=="restaurant"] <- "nichtWohnen"

rolle_bld_out$nutzung[is.na(rolle_bld_out$nutzung)] <- "nichtWohnen"

Fenster Attribute nach Nutzung zuweisen

rolle_bld_out$fensterFl<-NA
rolle_bld_out$fensterFl[rolle_bld_out$nutzung=="wohnen"]<-rolle_bld_out$fensterFl_wohnen[rolle_bld_out$nutzung=="wohnen"]
rolle_bld_out$fensterFl[rolle_bld_out$nutzung=="nichtWohnen"]<-rolle_bld_out$fensterFl_nichtWohnen[rolle_bld_out$nutzung=="nichtWohnen"]

rolle_bld_out$fensterFl_proz<-NA
rolle_bld_out$fensterFl_proz[rolle_bld_out$nutzung=="wohnen"]<-rolle_bld_out$prozFl_wohnen[rolle_bld_out$nutzung=="wohnen"]
rolle_bld_out$fensterFl_proz[rolle_bld_out$nutzung=="nichtWohnen"]<-rolle_bld_out$prozFl_nichtWohnen[rolle_bld_out$nutzung=="nichtWohnen"]

rolle_bld_out$fensterFl_breite<-NA
rolle_bld_out$fensterFl_breite[rolle_bld_out$nutzung=="wohnen"]<-rolle_bld_out$fensterFl_wohnen_breite[rolle_bld_out$nutzung=="wohnen"]
rolle_bld_out$fensterFl_breite[rolle_bld_out$nutzung=="nichtWohnen"]<-rolle_bld_out$fensterFl_nichtWohnen_breite[rolle_bld_out$nutzung=="nichtWohnen"]

rolle_bld_out$fensterFl_laenge<-NA
rolle_bld_out$fensterFl_laenge[rolle_bld_out$nutzung=="wohnen"]<-rolle_bld_out$fensterFl_wohnen_laenge[rolle_bld_out$nutzung=="wohnen"]
rolle_bld_out$fensterFl_laenge[rolle_bld_out$nutzung=="nichtWohnen"]<-rolle_bld_out$fensterFl_nichtWohnen_laenge[rolle_bld_out$nutzung=="nichtWohnen"]

Klassifikation EFH / MFH

rolle_bld_out$typ<-NA
rolle_bld_out$typ[rolle_bld_out$sia=="efh"] <- "efh"

rolle_bld_out$typ[rolle_bld_out$sia=="alterheim"|
                        rolle_bld_out$sia=="mischnutzung"|
                        rolle_bld_out$sia=="krankenhaus"|
                        rolle_bld_out$sia=="hotel"|
                        rolle_bld_out$sia=="restaurant"] <- "mfh"

rolle_bld_out$typ[is.na(rolle_bld_out$typ)] <- "mfh"

U-Werte nach Gebäudetyp zuweisen

rolle_bld_out$uVal_ground<-NA
rolle_bld_out$uVal_roof<-NA
rolle_bld_out$uVal_wall<-NA
rolle_bld_out$uVal_window<-NA

rolle_bld_out$uVal_ground[rolle_bld_out$typ=="efh"]<-rolle_bld_out$uVal_efh_ground[rolle_bld_out$typ=="efh"]
rolle_bld_out$uVal_ground[rolle_bld_out$typ=="mfh"]<-rolle_bld_out$uVal_mfh_ground[rolle_bld_out$typ=="mfh"]

rolle_bld_out$uVal_roof[rolle_bld_out$typ=="efh"]<-rolle_bld_out$uVal_efh_roof[rolle_bld_out$typ=="efh"]
rolle_bld_out$uVal_roof[rolle_bld_out$typ=="mfh"]<-rolle_bld_out$uVal_mfh_roof[rolle_bld_out$typ=="mfh"]

rolle_bld_out$uVal_wall[rolle_bld_out$typ=="efh"]<-rolle_bld_out$uVal_efh_wall[rolle_bld_out$typ=="efh"]
rolle_bld_out$uVal_wall[rolle_bld_out$typ=="mfh"]<-rolle_bld_out$uVal_mfh_wall[rolle_bld_out$typ=="mfh"]

rolle_bld_out$uVal_window[rolle_bld_out$typ=="efh"]<-rolle_bld_out$uVal_efh_window[rolle_bld_out$typ=="efh"]
rolle_bld_out$uVal_window[rolle_bld_out$typ=="mfh"]<-rolle_bld_out$uVal_mfh_window[rolle_bld_out$typ=="mfh"]

Sanierungswerte nur für alte Gebäude

rolle_bld_out$uVal_ground_saniert[rolle_bld_out$GBAUJ>2000]<-NA
rolle_bld_out$uVal_roof_saniert[rolle_bld_out$GBAUJ>2000]<-NA
rolle_bld_out$uVal_wall_saniert[rolle_bld_out$GBAUJ>2000]<-NA
rolle_bld_out$uVal_window_saniert[rolle_bld_out$GBAUJ>2000]<-NA

rolle_bld_out$gVal_saniert[rolle_bld_out$GBAUJ>2000]<-NA

Attribute auswählen

rolle_bld_out@data<-rolle_bld_out@data[,c("EGID","GAREA","GASTW","GBAUJ","ebf","GKLAS_text",
                                          "GHEIZ_text","GENHZ_text","GENWW_text","GKAT_text","GWWV",
                                          "sia","siaNr","nutzung","typ",
                                          "uVal_ground","uVal_roof","uVal_wall","uVal_window",
                                          "uVal_ground_saniert",
                                          "uVal_roof_saniert","uVal_wall_saniert","uVal_window_saniert",
                                          "gVal","gVal_saniert",
                                          "fensterFl","fensterFl_breite","fensterFl_laenge","fensterFl_proz",
                                          "longitude","latitude","breite","laenge","ausricht",
                                          "enerBed_awel","enerBed_ss","enerBed_vd","nutzungsgrad",
                                          "kbob_PEne","kbob_PEer","kbob_GHG",
                                          "bestand_Geraete","bestand_Beleuchtung","bestand_Lueftung","bestand_Klimakaelte",
                                          "bestand_Heizwaerme","bestand_Warmwasser")]

rolle_bld_out$GBAUP<-cut(as.numeric(rolle_bld_out$GBAUJ),
                           breaks=c(0,1919,1945,1960,1970,1980,1985,1990,1995,2000,2005,2010,2015,2500),
                           labels = c("vor 1919","1920-1945","1946-1960","1961-1970",
                                      "1971-1980","1981-1985","1986-1990","1991-1995",
                                      "1991-2000","2001-2005","2006-2010","2011-2015","nach 2015"))

rolle_bld_tbl<-rolle_bld_out@data

some plots

#daten für karte aufbereiten
rolle_bld_out.wgs<-spTransform(rolle_bld_out,CRSobj = CRS("+init=epsg:4326"))
rolle_bld_out.wgs.f = fortify(rolle_bld_out.wgs,by="EGID")
## Regions defined for each Polygons
rolle_bld_out.wgs$id<-sapply(rolle_bld_out.wgs@polygons,function(x){x@ID})
rolle_bld_out.wgs.f<-merge(rolle_bld_out.wgs.f,rolle_bld_out.wgs@data,by="id")

#basemap
library(ggmap)
lat <- c(46.45083,46.47911)
long <- c(6.315,6.36)
bbox <- make_bbox(long,lat,f=0.05)
b <- get_map(bbox,maptype="toner-lite",source="stamen")
## Map from URL : http://tile.stamen.com/toner-lite/14/8479/5797.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8480/5797.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8481/5797.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8479/5798.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8480/5798.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8481/5798.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8479/5799.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8480/5799.png
## Map from URL : http://tile.stamen.com/toner-lite/14/8481/5799.png
##sia karte
#farben für sia kategorien auswählen
cols<- levels(factor(rolle_bld_out.wgs.f$sia))
color <- grDevices::colors()[grep('gr(a|e)y', grDevices::colors(), invert = T)]
    
    if(length(cols)>12){
      myColors<-color[sample(1:length(color),size=length(cols),replace=F)]
    }else{
      myColors <- brewer.pal(length(cols),"Set3")
    }
    
names(myColors) <- cols
colScale2 <- scale_fill_manual(name = "grp",values = myColors,drop=F)

#karte zeichnen
ggmap(b) + 
  geom_polygon(data = rolle_bld_out.wgs.f,
             aes(long,lat,group=group,fill=sia),alpha=0.9) +
  colScale2+
    theme(axis.title.x=element_blank(),
          axis.text.x=element_blank(),
          axis.ticks.x=element_blank(),
          axis.title.y=element_blank(),
          axis.text.y=element_blank(),
          axis.ticks.y=element_blank(),
          legend.title = element_blank())

##gebäudealter karte
#farben wählen
cc <- scales::seq_gradient_pal("blue","orange", "red")(seq(0,1,length.out=length(levels(factor(rolle_bld_out.wgs.f$GBAUP)))))
## Warning: Non Lab interpolation is deprecated
#karte zeichnen
ggmap(b) + 
  geom_polygon(data = rolle_bld_out.wgs.f,
             aes(long,lat,group=group,fill=GBAUP),alpha=0.9) +
    theme(axis.title.x=element_blank(),
          axis.text.x=element_blank(),
          axis.ticks.x=element_blank(),
          axis.title.y=element_blank(),
          axis.text.y=element_blank(),
          axis.ticks.y=element_blank(),
          legend.title = element_blank())+
  scale_fill_manual(values=cc)

#energiebedarf karte
rolle_bld_pts <- gCentroid(rolle_bld_out.wgs,byid=TRUE)

ggmap(b) + 
  geom_polygon(data = rolle_bld_out.wgs.f,
             aes(long,lat,group=group), fill="grey50",alpha=0.5) +
  geom_point(data=rolle_bld_out.wgs@data,
             aes(x = rolle_bld_pts@coords[,1],
                 y = rolle_bld_pts@coords[,2], 
                 size=enerBed_vd),
             shape=1,
             color="black",alpha=1)+
  theme(axis.title.x=element_blank(),
          axis.text.x=element_blank(),
          axis.ticks.x=element_blank(),
          axis.title.y=element_blank(),
          axis.text.y=element_blank(),
          axis.ticks.y=element_blank(),
          legend.title = element_text())+
  scale_radius(breaks=round(seq(from=0,to = max(rolle_bld_out.wgs$enerBed_vd,na.rm=T),by = 300000)),range = c(.5, 10))+ guides(size=guide_legend(title="Energiebedarf (kWh/a)"))
## Warning: Removed 65 rows containing missing values (geom_point).

Save all Information

writeOGR(rolle_bld_out, "output/06_output/geom", "06_rolle_bld_out", driver="ESRI Shapefile",overwrite_layer = T)
## Warning in writeOGR(rolle_bld_out, "output/06_output/geom",
## "06_rolle_bld_out", : Field names abbreviated for ESRI Shapefile driver
#buildings speichern
write.csv(rolle_bld_tbl,file="output/06_output/data/06_rolle_bld_out.csv")